package com.itheima.f;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        test1();
        test2();
    }

    public static void test1() {
        FileWriter fw = null;
        try {
            fw = new FileWriter("E:/a.txt");
            fw.write("HelloWorld");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }

    public static void test2() {
        try (
                FileWriter fw = new FileWriter("E:/b.txt");
        ) {
            fw.write("HelloWorld");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
